<?php
/**
 * Created by PhpStorm.
 * userValidate: hms
 * Date: 2018/11/26
 * Time: 15:23
 */
namespace app\firm\validate;

use think\Validate;

class bankValidate extends Validate
{

    protected $rule = [
        'bank_mobile' =>  'require|checkTel:thinkphp',
        'bank_num' =>  'require|checkBank:thinkphp',
        'bank_name'  =>  'require',
    ];

    protected $message = [
        'tel.require' => '请输入手机号',
        'bank_num.require' => '请输入银行卡号',
        'bank_name.require' => '请输入开户行',
    ];

    public function checkTel($value, $rule, $data = [])
    {
        return preg_match('#^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$#', $value) ? true : '手机号错误';
    }
    
    public function checkBank($value, $rule, $data = [])
    {
        return preg_match('/^([1-9]{1})(\d{14}|\d{18})$/', $value) ? true : '银行卡号错误';
    }

}